<template>
  <div class="web">
    <div class="webLeft">
      <menuleft :menuList="menuList" :menuFlag="showFlag" @handleMenu="handleMenu" />
    </div>
    <div class="webRight">
      <!-- <keep-alive></keep-alive> -->
      <projectList @subset="subset" :pns="pns" v-if="showFlag == '0' || showFlag == '10'" />
      <projectClose @subset="subset" v-if="showFlag == '11'" />
      <presales @subset="subset" v-if="showFlag == '28'" />
      
      <memberMent :projectid="projectid" :pn="pn" @subset="subset" v-if="showFlag == '1'" />
      <manHour :projectid="projectid" :pn3="pn3" @subset="subset" v-if="showFlag == 2" />
      <manHourClose :projectid="projectid" @subset="subset" v-if="showFlag == '3'" />
    </div>
  </div>
</template>

<script>
import projectList from "./projectList"; //正式项目
import memberMent from "./memberMent"; //成员管理
import manHour from "./manHour"; //查看当前项目工时
import manHourClose from "./manHourClose"; //查看已关闭项目工时
import projectClose from "./projectClose"; //已关闭项目页面
import plateMent from "./plateMent"; //板块管理
import presales from "./presales"; //售前模块
import { getUserAuthResourceList } from "@/service/Api.js"; //接口
import menuleft from "@/components/menuItem/menuleft.vue";

export default {
  components: {
    projectList,
    memberMent,
    manHour,
    presales,
    projectClose,
    plateMent,
    menuleft,
    manHourClose,
  },
  inject: ['reload'],
  name: "projectMent",
  data() {
    return {
      title: "",
      menuList: [
        {
          name: "项目管理",
          id: "3",
          children: [],
        },
      ],
      showFlag: "",
      projectid: "",
      pn:"",
      pns:"",
    };
  },
  created() {
    this.init();
  },
  mounted() {
    // this.showFlag = '28'
    sessionStorage.setItem("showFlag", "10");
  },
  methods: {
    init() {
      // 获取当前角色下的二级列表
      getUserAuthResourceList(this.menuList[0].id).then((res) => {
        if (res.code == 0) {
          this.menuList[0].children = res.data;
          this.showFlag = this.$route.query.isclose1
            ? "28"
            : this.$route.query.isclose2
              ? "11"
              : res.data[1].id.toString();
        } else {
          this.$message.error(`${res.data}`);
        }
      });
    },
    handleCommon(name, row, idx) {
      if (this[name]) {
        this[name](row, idx);
      }
    },
    handleMenu(id) {
      this.showFlag = id;
      sessionStorage.setItem("showFlag", id);
    },
    //子菜单0-主页面 1-项目成员管理 2-查看工时
    subset(val) {
      this.projectid = val.projectid;
      this.showFlag = val.falg.toString();
      // sessionStorage.setItem("showFlag", null)
      sessionStorage.setItem("name", val.name);
      this.$store.commit("SET_PROJECT_NAME", val.name);
      console.log("showFlag",val.falg);
      if(val.pn3){
        this.pn3 = val.pn3;
        this.pns = val.pn3;
      }else{
        this.pn = val.pn;
        this.pns = val.pn;
      };
      // console.log("val",val);
      // console.log("左边标签栏接收pn",this.pn);
      this.$emit('goPn',{pn:this.pn});
    },
  },
};
</script>

<style scoped></style>
